<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('诗单详情列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <form id="formId">
                <input type="hidden" id="setId" name="setId" th:value="${poemSet.id}"/>
            </form>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="poem:poemsetdetail:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="poem:poemsetdetail:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="poem:poemsetdetail:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="poem:poemsetdetail:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('poem:poemsetdetail:edit')}]];
        var removeFlag = [[${@permission.hasPermi('poem:poemsetdetail:remove')}]];
        var prefix = ctx + "poem/poemsetdetail";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "诗单详情",
                sortName: "sort",
		        sortOrder: "asc",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'poemId', 
                    title : '诗词ID'
                },
                {
                    field : 'mingcheng', 
                    title : '诗词'
                },
                {
                    field : 'zuozhe', 
                    title : '作者'
                },
                {
                    field : 'sort', 
                    title : '排序'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        //导入表结构
		function add() {
        	var setId = $("#setId").val();
			var importPoemUrl = prefix + "/importPoem/" + setId;
			$.modal.open("添加诗词", importPoemUrl);
		}
        
    </script>
</body>
</html>